package com.yuan.kafkastudy.constant;

public enum MessageEnum {

    SUCCESS(0,"发送成功"),
    FAIL(1,"发送失败");

    private final int code;
    private final String message;

    MessageEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }
    public String getMessage() {
        return message;
    }
    // 根据 code 反查枚举
    public static MessageEnum of(int code) {
        for (MessageEnum s : values()) {
            if (s.code == code) return s;
        }
        throw new IllegalArgumentException("非法code: " + code);
    }
}
